package com.example.springbootuploadanddownload.controller;

import com.example.springbootuploadanddownload.service.FilesService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 从数据库下载
 */
@RestController
@Slf4j
@RequestMapping("/db")
public class DownloadFromDBController {

    @Autowired
    private FilesService filesService;

    @GetMapping("/download/{id}")
    public void download(HttpServletResponse response, @PathVariable("id") Integer id) {
        filesService.download(response,id);
    }
}
